<?php
/**
 * 内容管理
 */

class Model_Comment {
	
	/**
	 * 添加内容
	 *
	 * @param $data array        	
	 */
	public function add_Comment($data) {
		if (! is_array ( $data )) {
			return false;
		}
		
		$DB_Comment = new DB_Comment ();
		return $DB_Comment->insert ( $data );
	}
	
	/**
	 * 取评论信息
	 *
	 * @param $id int        	
	 */
	public function Get_Comment($id) {
		if (empty ( $id ) || ! is_numeric ( $id )) {
			return false;
		}
		
		$DB_Comment = new DB_Comment ();
		$Comment_Info = $DB_Comment->loadInfoByPrimary ( $id );
		$Comment_Info ['ctime'] = date ( "Y-m-d H:i:s", $Comment_Info ['ctime'] );
		
		return $Comment_Info;
	}
	
	/**
	 * 编辑内容
	 *
	 * @param $id int        	
	 * @param $data array        	
	 */
	public function edit_Comment($id, $data) {
		if (! is_array ( $data ) || empty ( $id )) {
			return false;
		}
		
		$DB_Comment = new DB_Comment ();
		if ($DB_Comment->updateByConditions ( $data, "id={$id}" )) {
			return true;
		}
		return false;
	}
	
	/**
	 * 删除内容
	 *
	 * @param $id int        	
	 */
	public function delete_Comment($id) {
		if (empty ( $id )) {
			return false;
		}
		$DB_Comment = new DB_Comment ();
		$DB_Comment->delete ( "id in({$id})" );
		return true;
	}
}
?>